<?php

	// +----------------------------------------------------------------------
	// | 订单日志
	// +----------------------------------------------------------------------
	// | Copyright (c) 2015-2024 http://www.yicmf.com, All rights reserved.
	// +----------------------------------------------------------------------
	// | Author: 微尘 <yicmf@qq.com>
	// +----------------------------------------------------------------------

	namespace app\model\store;

	use app\model\file\Image;

	class OrderGood extends Common
	{
	    public function good()
		{
			return $this->belongsTo(Good::class);
		}

		public function sku()
		{
			return $this->belongsTo(GoodSku::class,'sku_id');
		}

		public function cover()
		{
			return $this->belongsTo(Image::class, 'cover_id');
		}

		public function store()
		{
			return $this->belongsTo(Store::class);
		}

		/**
		 * 写入修改
		 * @param $data
		 */
		public static function onBeforeInsert($data)
		{
			$data['status'] = 1;
			$data['ip'] = request()->ip();
		}
	}
